package com.codejoys.ssm.web;


import com.codejoys.ssm.domain.Discipline;
import com.codejoys.ssm.domain.School;
import com.codejoys.ssm.dto.BaseResult;
import com.codejoys.ssm.dto.PageData;
import com.codejoys.ssm.service.DisciplineService;
import com.codejoys.ssm.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

public class DisciplineController {

    @Autowired
    DisciplineService disciplineService;

    @GetMapping("findById")
    @ResponseBody
    public BaseResult findBySchoolId(School school){
        List<Discipline> bySchoolId = disciplineService.findBySchoolId(school);
        BaseResult baseResult = BaseResult.success();
        baseResult.setData(bySchoolId);
        return baseResult;
    }

    @GetMapping("findByDiscipline")
    @ResponseBody
    public BaseResult findByDiscipline(Discipline discipline){
        List<School> byDiscipline = disciplineService.findByDiscipline(discipline);
        BaseResult baseResult = BaseResult.success();
        baseResult.setData(byDiscipline);
        return baseResult;
    }
}
